package com.corn.turorial.spring.actuator;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : Jim Wu
 * @version 1.0
 * @function :
 * @since : 2021/2/4 15:20
 */

@Component
public class MyInfoEndpointInfoContributor implements InfoContributor {
    @Value("${server.port}")
    private int port;

    @Value("${spring.application.name}")
    private String applicationName;

    @Override
    public void contribute(Info.Builder builder) {
        Map<String, Object> infos = new HashMap<>();
        infos.put("applicationName", applicationName);
        infos.put("port", port);
        builder.withDetails(infos);
    }
}
